package li.webqq.api;

import li.http.Response;

/**
 * @author 明伟
 */
public class CheckResponse extends Response {
    private String uin16;

    private String flag;

    private String verifyCode;

    public String getUin16() {
        if (null == this.uin16) {
            String body = super.getBody();
            try {
                this.uin16 = body.substring(body.lastIndexOf(',') + 2, body.length() - 3);
            } catch (Exception e) {
                throw new RuntimeException(body, e);
            }
        }
        return this.uin16;
    }

    public String getFlag() {
        if (null == this.flag) {
            String body = super.getBody();
            this.flag = body.substring(14, 15);
        }
        return this.flag;
    }

    public Boolean needGetImage() {
        return !"0".equals(getFlag());
    }

    public String getVerifyCode() {
        if (null == this.verifyCode) {
            if ("0".equals(this.getFlag())) {
                String body = super.getBody();
                this.verifyCode = body.substring(18, 22);
            }
        }
        return this.verifyCode;
    }
}